/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vita.vitasolution.service.rest;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.*;
import vita.vitasolution.db.entities.Wallet;

/**
 *
 * @author harker777
 */
@Stateless
@Path("wallet")
public class WalletFacadeREST extends AbstractFacade<Wallet> {

	@PersistenceContext(unitName = "VitaSolutionPU")
	private EntityManager em;

	public WalletFacadeREST() {
		super(Wallet.class);
	}

	@POST
	@Override
	@Consumes({"application/xml", "application/json"})
	public void create(Wallet entity) {
		super.create(entity);
	}

	@PUT
	@Override
	@Consumes({"application/xml", "application/json"})
	public void edit(Wallet entity) {
		super.edit(entity);
	}

	@DELETE
	@Path("{id}")
	public void remove(
			@PathParam("id") Integer id) {
		super.remove(super.find(id));
	}

	@GET
	@Path("{id}")
	@Produces({"application/xml", "application/json"})
	public Wallet find(
			@PathParam("id") Integer id) {
		return super.find(id);
	}

	@GET
	@Override
	@Produces({"application/xml", "application/json"})
	public List<Wallet> findAll() {
		return super.findAll();
	}

	@GET
	@Path("{from}/{to}")
	@Produces({"application/xml", "application/json"})
	public List<Wallet> findRange(
			@PathParam("from") Integer from,
			@PathParam("to") Integer to) {
		return super.findRange(new int[]{from, to});
	}

	@GET
	@Path("count")
	@Produces("text/plain")
	public String countREST() {
		return String.valueOf(super.count());
	}

	@Override
	protected EntityManager getEntityManager() {
		return em;
	}
}
